<!--
人像库类型 下拉框
-->
<template>
  <el-select
    v-on="$listeners"
    v-bind="$attrs"
    collapse-tags
    v-model="_lib"
    :multiple="multiple"
    @change="$emit('change', _lib)"
    :placeholder="$t('common.pleaseSelect')"
  >
    <el-option
      v-for="item in lib_type_list"
      :key="item.value"
      :label="item.label"
      :value="item.value"
    ></el-option>
  </el-select>
</template>

<script>
export default {
  model: {
    prop: "lib",
    event: "change",
  },
  props: {
    // 父组件传过来的值
    lib: {
      type: String,
      default: void 0,
    },
    // 是否包含全部
    // 默认不包含
    includes:{
      type:Array,
      default:()=>[  { label: this.$t("common.all"), value: void 0 },]
    },
    multiple: {
      type: Boolean,
      default: false,
    },
  },
  watch: {
    lib: {
      handler(val) {
        this._lib = val;
      },
      immediate: true,
    },
    includes:{
      handler(val) {
        this.lib_type_list = [...this.includes,...this.lib_type_list]
      },
      immediate: true,
    }
  },
  created() {},
  data() {
    return {
      lib_type_list: [
        { label: this.$t("renxiangkuguanli.blackLib"), value: 1 },
        { label: this.$t("renxiangkuguanli.whiteLib"), value: 2 },
        { label: this.$t("route.moshengrenku"), value: 0 },
      ],
    };
  },
  computed: {
    _lib: {
      get() {
        return this.lib;
      },
      set(val) {
        this.$emit("change", val);
      },
    },
  },
};
</script>

<style></style>
